package org.dtrd.modules.questionnaire.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.modules.questionnaire.entity.bean.PatientBasicInfo;
import org.dtrd.modules.questionnaire.entity.bean.QuestionnaireRdVersionDetail;

import java.util.Date;


/**
 * <p>
 * 调查问卷
 * </p>
 *
 * @author QR
 * @since 2022-02-15
 */
@Getter
@Setter
@TableName("dtrd_ent_questionnaire_rd_reversion")
public class DtrdEntQuestionnaireRdReversion {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 姓名
     */
    @TableField("name")
    private String name;

    /**
     * 患者id
     */
    @TableField("patient_id")
    private Integer patientId;

    @TableField("phone")
    private String phone;

    /**
     * 性别, 1-男, 2-女
     */
    @TableField("sex")
    private Integer sex;

    /**
     * 糖尿病确诊情况, 1-未确诊, 2-已确诊
     */
    @TableField("diabetes_diagnosis")
    private Integer diabetesDiagnosis;

    /**
     * 糖尿病类型：1-1型糖尿病,2-2型糖尿病,3-妊娠糖尿病,4-其他类型糖尿病
     */
    @TableField("diabetes_type")
    private Integer diabetesType;

    /**
     * 糖尿病确诊日期
     */
    @TableField("diabetes_diagnosis_date")
    private Date diabetesDiagnosisDate;

    /**
     * 糖尿病家族史
     */
    @TableField("diabetes_family_history")
    private Integer diabetesFamilyHistory;

    /**
     * 用药情况, 1-吃药, 2-打胰岛素, 3-吃药和打胰岛素, 4-不用药
     */
    @TableField("drug_history")
    private Integer drugHistory;

    /**
     * 身高
     */
    @TableField("height")
    private Float height;

    /**
     * 体重
     */
    @TableField("weight")
    private Float weight;

    /**
     * 腰围
     */
    @TableField("waist_line")
    private Integer waistLine;

    /**
     * C肽
     */
    @TableField("c_peptide")
    private Float cPeptide;

    /**
     * C肽-餐后两小时
     */
    @TableField("c_peptide_2h")
    private Float cPeptide2h;

    /**
     * 糖尿病并发症, 1-有, 2-无
     */
    @TableField("diabetes_complication")
    private Integer diabetesComplication;

    /**
     * 并发症症状
     */
    @TableField("diabetes_complication_symptom")
    private String diabetesComplicationSymptom;

    /**
     * 并发症其他症状
     */
    @TableField("diabetes_complication_symptom_other")
    private String diabetesComplicationSymptomOther;

    @TableField("create_time")
    private Date createTime;

    @TableField("result")
    private Integer result;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    public DtrdEntQuestionnaireRdReversion init() {
        createTime = new Date();
        isDel = 0;
        return this;
    }

    public DtrdEntQuestionnaireRdReversion parseFromDTO(QuestionnaireRdVersionDetail dto) {
        dataId = dto.getDataId();
        name = dto.getName();
        phone = dto.getPhone();
        patientId = dto.getPatientId();
        sex = dto.getSex();
        diabetesDiagnosis = dto.getDiabetesDiagnosis();
        diabetesType = dto.getDiabetesType();
        diabetesDiagnosisDate = dto.getDiabetesDiagnosisDate();
        diabetesFamilyHistory = dto.getDiabetesFamilyHistory();
        drugHistory = dto.getDrugHistory();
        height = dto.getHeight();
        weight = dto.getWeight();
        if (dto.getWaistline() != null) {
            waistLine = dto.getWaistline().intValue();
        }
        cPeptide = dto.getCPeptide();
        cPeptide2h = dto.getCPeptide2h();
        diabetesComplication = dto.getDiabetesComplication();
        diabetesComplicationSymptom = dto.getDiabetesComplicationSymptom();
        diabetesComplicationSymptomOther = dto.getDiabetesComplicationSymptomOther();
        return this;
    }


    public DtrdEntQuestionnaireRdReversion parseFromDTO(PatientBasicInfo dto) {
        name = dto.getName();
        patientId = dto.getPatientId();
        sex = dto.getSex();
        diabetesDiagnosis = dto.getDiabetesDiagnosis();
        diabetesType = dto.getDiabetesType();
        diabetesDiagnosisDate = dto.getDiabetesDiagnosisDate();
        return this;
    }
}
